﻿Public Class ViewAllUsers
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btn_findByName_Click(sender As Object, e As EventArgs) Handles btn_findByName.Click
        searchDatabase("FirstName", tb_search.Text)
    End Sub

    Protected Sub btn_findByRegion_Click(sender As Object, e As EventArgs) Handles btn_findByRegion.Click
        searchDatabase("Tourist", tb_search.Text)
    End Sub

    Private Function searchDatabase(ByVal buttonStr As String, ByVal searchStr As String)
        SqlDataSource2.SelectCommand = "SELECT * FROM Profiles WHERE " & buttonStr & " LIKE '%" & searchStr & "%'"
        SqlDataSource2.DataBind()
        Return True
    End Function

    Protected Sub SqlDataSource1_Selected(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource2.Selected
        If (e.AffectedRows < 13) Then
            DataPagerProfiles.Visible = False
        Else
            DataPagerProfiles.Visible = True
        End If
    End Sub

    Protected Sub ListView2_DataBound(sender As Object, e As EventArgs)
        'Display datapager only if there is more than one page to display
        DataPagerProfiles.Visible = (DataPagerProfiles.PageSize < DataPagerProfiles.TotalRowCount)
    End Sub

End Class